package com.neusoft.courseSelect.service.impl;

import com.neusoft.courseSelect.service.IAIService;
import com.neusoft.data.domain.SerChatHistory;
import com.neusoft.data.mapper.SerChatHistoryMapper;
import com.neusoft.wenXinYiYan.domain.Responce;
import com.neusoft.wenXinYiYan.service.impl.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AIService implements IAIService {

    @Autowired
    private SerChatHistoryMapper chatHistoryMapper;

    @Autowired
    private AiService aiService;

    @Override
    public String answerQuestion(String question, Long userId, String uuid, String realName) {
        SerChatHistory history = new SerChatHistory();

        history.setUserId(userId);
        history.setUserMsg(question);
        history.setSessionId(uuid);
        history.setUseFrom("1");
        history.setRealName(realName);

        history.setUseFrom("2");
        Responce responce = aiService.answer(question);
        history.setServiceMsg(responce.getResult());
        chatHistoryMapper.insertSerChatHistory(history);

        return responce.getResult();

    }
}
